home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Workbench Add-On
/
Workbench Add-On - Volume 1.iso
/
Dev
/
Oberon
/
source
/
amiga
/
DiskFont.mod
< prev
next >
Wrap
Text File
|
1995-06-29
|
21KB
|
563 lines
(***************************************************************************
$RCSfile: DiskFont.mod $
Description: Interface to diskfont.library
Created by: fjc (Frank Copeland)
$Revision: 3.8 $
$Author: fjc $
$Date: 1995/06/04 23:13:14 $
Includes Release 40.15
(C) Copyright 1985-1993 Commodore-Amiga, Inc.
All Rights Reserved
Oberon-A interface Copyright © 1994-1995, Frank Copeland.
This file is part of the Oberon-A Interface.
See Oberon-A.doc for conditions of use and distribution.
***************************************************************************)
<* STANDARD- *>
MODULE [2] DiskFont;
IMPORT
SYS := SYSTEM, Kernel, e := Exec, d := Dos, u := Utility, gfx := Graphics,
s := Sets;
(*
** $VER: diskfont.h 38.0 (18.6.92)
**
** diskfont library definitions
**
** (C) Copyright 1990 Robert R. Burns
** All Rights Reserved
*)
CONST
maxFontPath * = 256; (* including null terminator *)
TYPE
FontContentsPtr * = POINTER TO FontContents;
FontContents * = RECORD
fileName * : ARRAY maxFontPath OF CHAR;
ySize * : e.UWORD;
style * : s.SET8;
flags * : s.SET8;
END; (* FontContents *)
TFontContentsPtr * = POINTER TO TFontContents;
TFontContents * = RECORD
fileName * : ARRAY maxFontPath - 2 OF CHAR;
tagCount * : e.UWORD; (* including the tagDONE tag *)
(*
* if tagCount is non-zero, fileName is overlayed with
* Text Tags starting at: SYS.VAL (u.TagItemPtr,
* SYS.ADR (fileName[maxFontPath-(tagCount*SIZE (u.TagItem))]))
*)
ySize * : e.UWORD;
style * : s.SET8;
flags * : s.SET8;
END; (* TFontContents *)
CONST
fchId * = 0F00H; (* FontContentsHeader, then FontContents *)
tfchId * = 0F02H; (* FontContentsHeader, then TFontContents *)
ofchId * = 0F03H; (* FontContentsHeader, then TFontContents,
* associated with outline font *)
TYPE
FontContentsHeaderPtr * = POINTER TO FontContentsHeader;
FontContentsHeader * = RECORD
fileID * : e.UWORD; (* fchID *)
numEntries * : e.UWORD; (* the number of FontContents elements *)
(**fc * : ARRAY numEntries OF FontContents or
tfc * : ARRAY numEntries OF TFontContents *)
END; (* FontContentsHeader *)
CONST
dfhId * = 0F80H;
maxFontName * = 32; (* font name including ".font\0" *)
TYPE
DiskFontHeaderPtr * = POINTER TO DiskFontHeader;
(* the following 8 bytes are not actually considered a part of the *)
(* DiskFontHeader, but immediately preceed it. The nextSegment is *)
(* supplied by the linker/loader, and the returnCode is the code *)
(* at the beginning of the font in case someone runs it... *)
(* nextSegment : e.ULONG; (* actually a BPTR *) *)
(* returnCode : e.ULONG; (* MOVEQ #0,D0 : RTS *) *)
(* here then is the official start of the DiskFontHeader... *)
DiskFontHeader * = RECORD (e.NodeBase)
df * : e.Node; (* node to link disk fonts *)
fileID * : e.UWORD; (* dfhID *)
revision * : e.UWORD; (* the font revision *)
segment * : e.BPTR; (* the segment address when loaded *)
name * : ARRAY maxFontName OF CHAR; (* the font name (null terminated) *)
tf * : gfx.TextFont; (* loaded TextFont structure *)
END; (* DiskFontHeader *)
(* unfortunately, this needs to be explicitly typed *)
(* used only if tf.tfStyle fsTagged bit is set *)
(* DiskFontHeader.tagList = DiskFontHeader.segment; (* destroyed during loading *)*)
CONST
memory * = 0;
disk * = 1;
scaled * = 2;
bitmap * = 3;
tagged * = 16; (* return TAvailFonts *)
TYPE
AvailFontPtr * = POINTER TO AvailFont;
AvailFont * = RECORD
type * : s.SET16; (* MEMORY, DISK, or SCALED *)
attr * : gfx.TextAttr; (* text attributes for font *)
END; (* AvailFont *)
TAvailFontPtr * = POINTER TO TAvailFont;
TAvailFont * = RECORD
Type * : s.SET16; (* MEMORY, DISK, or SCALED *)
Attr * : gfx.TTextAttr; (* text attributes for font *)
END; (* TAvailFont *)
AvailFontsHeaderPtr * = POINTER TO AvailFontsHeader;
AvailFontsHeader * = RECORD
numEntries * : e.UWORD; (* number of AvailFonts elements *)
(**af * : ARRAY numEntries OF AvailFont or
taf * : ARRAY numEntries OF TAvailFont*)
END; (* AvailFontsHeader *)
(*
** $VER: diskfonttag.h 10.4 (14.7.92)
**
** libraries/diskfonttag.h -- tag definitions for .otag files
**
** (C) Copyright 1990-1992 Robert R. Burns
** All Rights Reserved
*)
CONST
(* Level 0 entries never appear in the .otag tag list, but appear in font
* specifications *)
level0 * = u.user;
(* Level 1 entries are required to exist in the .otag tag list *)
level1 * = u.user + 1000H;
(* Level 2 entries are optional typeface metric tags *)
level2 * = u.user + 2000H;
(* Level 3 entries are required for some engines *)
level3 * = u.user + 3000H;
(* Indirect entries are at (tag address + data offset) *)
indirect * = 8000H;
(********************************************************************)
(* font specification and inquiry tags *)
(* ! tags flagged with an exclaimation mark are valid for
* specification.
* ? tags flagged with a question mark are valid for inquiry
*
* fixed binary numbers are encoded as 16 bits of integer and
* 16 bits of fraction. Negative values are indicated by twos
* complement of all 32 bits.
*)
(* ! deviceDPI specifies the target device dots per inch -- X DPI is
* in the high word, Y DPI in the low word. *)
deviceDPI * = level0 + 01H; (* == taDeviceDPI *)
(* ! dotSize specifies the target device dot size as a percent of
* it's resolution-implied size -- X percent in high word, Y percent
* in low word. *)
dotSize * = level0 + 02H;
(* ! OT_Point_Height specifies the requested point height of a typeface,
* specifically, the height and nominal width of the em-square.
* The point referred to here is 1/72". It is encoded as a fixed
* binary number. *)
pointHeight * = level0 + 08H;
(* ! setFactor specifies the requested set width of a typeface.
* It distorts the width of the em-square from that specified by
* pointHeight. To compensate for a device with different
* horizontal and vertical resolutions, deviceDpi should be used
* instead. For a normal aspect ratio, set to 1.0 (encoded as
* 0x00010000). This is the default value. *)
setFactor * = level0 + 09H;
(* ! shear... specifies the Sine and Cosine of the vertical stroke
* angle, as two fixed point binary fractions. Both must be specified:
* first the Sine and then the Cosine. Setting the sine component
* changes the Shear to an undefined value, setting the cosine
* component completes the Shear change to the new composite value.
* For no shear, set to 0.0, 1.0 (encoded as 0x00000000, 0x00010000).
* This is the default value. *)
shearSin * = level0 + 0AH;
shearCos * = level0 + 0BH;
(* ! rotate... specifies the Sine and Cosine of the baselin rotation
* angle, as two fixed point binary fractions. Both must be specified:
* first the Sine and then the Cosine. Setting the sine component
* changes the Shear to an undefined value, setting the cosine
* component completes the Shear change to the new composite value.
* For no shear, set to 0.0, 1.0 (encoded as 0x00000000, 0x00010000).
* This is the default value. *)
rotateSin * = level0 + 0CH;
rotateCos * = level0 + 0DH;
(* ! embolden... specifies values to algorithimically embolden -- or,
* when negative, lighten -- the glyph. It is encoded as a fixed point
* binary fraction of the em-square. The X and Y components can be
* changed indendently. For normal characters, set to 0.0, 0.0
* (encoded as 0x00000000, 0x00000000). This is the default value. *)
emboldenX * = level0 + 0EH;
emboldenY * = level0 + 0FH;
(* ! pointSize is an old method of specifying the point size,
* encoded as (points * 16). *)
pointSize * = level0 + 10H;
(* ! glyphCode specifies the glyph (character) code to use with
* subsequent operations. For example, this is the code for an
* glyph inquiry *)
glyphCode * = level0 + 11H;
(* ! glyphCode2 specifies the second glyph code. For example,
* this is the right glyph of the two glyphs of an kernPair
* inquiry *)
glyphCode2 * = level0 + 12H;
(* ! glyphWidth specifies a specific width for a glyph.
* It sets a specific escapement (advance) width for subsequent
* glyphs. It is encoded as a fixed binary fraction of the em-square.
* To revert to using the font-defined escapement for each glyph, set
* to 0.0 (encoded as 0x00000000). This is the default value. *)
glyphWidth * = level0 + 13H;
(* ! oTagPath and
* ! oTagList specify the selected typeface. Both must be specified:
* first the Path and then the List. Setting the path name changes
* changes the typeface to an undefined value, providing the List
* completes the typeface selection to the new typeface. OTagPath
* is the null terminated full file path of the .otag file associated
* with the typeface. OTagList is a memory copy of the processed
* contents of that .otag file (i.e. with indirections resolved).
* There are no default values for the typeface. *)
oTagPath * = level0 + indirect + 14H;
oTagList * = level0 + indirect + 15H;
(* ? glyphMap supplies a read-only struct GlyphMap pointer that
* describes a bitmap for a glyph with the current attributes. *)
glyphMap * = level0 + indirect + 20H;
(* ? widthList supplies a read-only struct MinList of struct
* GlyphWidthEntry nodes for glyphs that are defined from GlyphCode
* to GlyphCode2, inclusive. The widths are represented as fixed
* binary fractions of the em-square, ignoring any effect of
* SetFactor or GlyphWidth. A width would need to be converted to
* a distance along the baseline in device units by the
* application. *)
widthList * = level0 + indirect + 21H;
(* ? ...KernPair supplies the kern adjustment to be added to the
* current position after placement of the GlyphCode glyph and
* before placement of the GlyphCode2 glyph. Text kern pairs are
* for rendering body text. Display kern pairs are generally
* tighter values for display (e.g. headline) purposes. The
* adjustment is represented as a fixed binary fraction of the
* em-square, ignoring any effect of SetFactor. This number would
* need to be converted to a distance along the baseline in device
* units by the application. *)
textKernPair * = level0 + indirect + 22H;
designKernPair * = level0 + indirect + 23H;
(* ? underlined is an unsigned word which is used to request
* algorithimic underlining for the engine when rendering the glyph.
* Bullet.library currently does not support this tag, though it
* may be used by other engines in the future. The default for
* any engine which supports this tag must be ulNone. Engines which
* do not support this tag should return an appropriate err value.
*
* As of V39, diskfont.library will request underlining if specified
* in the TextAttr, or TTextAttr passed to OpenDiskFont(). Diskfont
* will first request Broken underlining (like the Text() function
* does when SetSoftStyle() is used), and then Solid underlining if
* the engine returns an error. If the engine returns an error for
* both, then diskfont.library attempts to find, or create the best
* non-underlined font that it can. *)
underLined * = level0 + 24H;
ulNone * = 0;
ulSolid * = 1;
ulBroken * = 2;
ulDoubleSolid * = 3;
outlDoubleBroken * = 4;
(* ? strikeThrough is a boolean which is used to request
* algorithimic strike through when rendering the glyph.
* Bullet.library currently does not support this tag, though it
* may be used by other engines in the future. The default for
* any engined which supports this tag must be FALSe. Engines which
* do not support this tag should return an appropriate err value. *)
strikeThrough * = level0 + 25H;
(********************************************************************)
(* .otag tags *)
(* suffix for files in FONTS: that contain these tags *)
suffix * = ".otag";
(* fileIdent both identifies this file and verifies its size.
* It is required to be the first tag in the file. *)
fileIdent * = level1 + 01H;
(* engine specifies the font engine this file is designed to use *)
engine * = level1 + indirect + 02H;
eBullet * = "bullet";
(* family is the family name of this typeface *)
family * = level1 + indirect + 03H;
(* The name of this typeface is implicit in the name of the .otag file *)
(* bName is used to find the bold variant of this typeface *)
bName * = level2 + indirect + 05H;
(* iName is used to find the italic variant of this typeface *)
iName * = level2 + indirect + 06H;
(* biName is used to find the bold italic variant of this typeface *)
biName * = level2 + indirect + 07H;
(* symSet is used to select the symbol set that has the otYSizeFactor
* described here. Other symbol sets might have different extremes *)
symbolSet * = level1 + 10H;
(* ySizeFactor is a ratio to assist in calculating the Point height
* to BlackHeight relationship -- high word: Point height term, low
* word: Black height term -- pointSize * = ysize*<high>/<low> *)
ySizeFactor * = level1 + 11H;
(* spaceWidth specifies the width of the space character relative
* to the character height *)
spaceWidth * = level2 + 12H;
(* isFixed is a boolean indicating that all the characters in the
* typeface are intended to have the same character advance *)
isFixed * = level2 + 13H;
(* serifFlag is a boolean indicating if the character has serifs *)
serifFlag * = level1 + 14H;
(* stemWeight is an unsigned byte indicating the weight of the character *)
stemWeight * = level1 + 15H;
sUltraThin * = 8; (* 0- 15 *)
sExtraThin * = 24; (* 16- 31 *)
sThin * = 40; (* 32- 47 *)
sExtraLight * = 56; (* 48- 63 *)
sLight * = 72; (* 64- 79 *)
sDemiLight * = 88; (* 80- 95 *)
sSemiLight * = 104; (* 96-111 *)
sBook * = 120; (* 112-127 *)
sMedium * = 136; (* 128-143 *)
sSemiBold * = 152; (* 144-159 *)
sDemiBold * = 168; (* 160-175 *)
sBold * = 184; (* 176-191 *)
sExtraBold * = 200; (* 192-207 *)
sBlack * = 216; (* 208-223 *)
sExtraBlack * = 232; (* 224-239 *)
sUltraBlack * = 248; (* 240-255 *)
(* slantStyle is an unsigned byte indicating the font posture *)
slantStyle * = level1 + 16H;
sUpright * = 0;
sItalic * = 1; (* Oblique, Slanted, etc. *)
sLeftItalic * = 2; (* Reverse Slant *)
(* horizStyle is an unsigned byte indicating the appearance width *)
horizStyle * = level1 + 17H;
hUltraCompressed * = 16; (* 0- 31 *)
hExtraCompressed * = 48; (* 32- 63 *)
hCompressed * = 80; (* 64- 95 *)
hCondensed * = 112; (* 96-127 *)
hNormal * = 144; (* 128-159 *)
hSemiExpanded * = 176; (* 160-191 *)
hExpanded * = 208; (* 192-223 *)
hExtraExpanded * = 240; (* 224-255 *)
(* spaceFactor specifies the width of the space character relative
* to the character height *)
spaceFactor * = level2 + 18H;
(* inhibitAlgoStyle indicates which style bits, if any, should
* be ignored even if the font does not already have that quality.
* For example, if fsBold is set and the typeface is not bold but
* the user specifies bold, the application or diskfont library is
* not to use embolden to achieve a bold result. *)
inhibitAlgoStyle * = level2 + 19H;
(* availSizes is an indirect pointer to sorted UWORDs, 0th is count *)
availSizes * = level1 + indirect + 20H;
maxAvailSizes * = 20; (* no more than 20 sizes allowed *)
(* specCount is the count number of parameters specified here *)
specCount * = level1 + 100H;
(* specs can be created as appropriate for the engine by ORing in the
* parameter number (1 is first, 2 is second, ... up to 15th) *)
spec * = level1 + 100H;
(* spec1 is the (first) parameter to the font engine to select
* this particular typeface *)
spec1 * = level1 + 101H;
(*
** $VER: glyph.h 9.1 (19.6.92)
**
** glyph.h -- structures for glyph libraries
**
** (C) Copyright 1991-1992 Robert R. Burns
** All Rights Reserved
*)
TYPE
(* A GlyphEngine must be acquired via OpenEngine and is read-only *)
GlyphEnginePtr * = POINTER TO GlyphEngine;
GlyphEngine * = RECORD
library - : e.LibraryPtr; (* engine library *)
name - : e.LSTRPTR; (* library basename: e.g. "bullet" *)
(* private library data follows... *)
END;
FIXED * = LONGINT; (* 32 bit signed w/ 16 bits of fraction *)
GlyphMapPtr * = POINTER TO GlyphMap;
GlyphMap * = RECORD
bmModulo * : e.UWORD; (* # of bytes in row: always multiple of 4 *)
bmRows * : e.UWORD; (* # of rows in bitmap *)
blackLeft * : e.UWORD; (* # of blank pixel columns at left *)
blackTop * : e.UWORD; (* # of blank rows at top *)
blackWidth * : e.UWORD; (* span of contiguous non-blank columns *)
blackHeight * : e.UWORD; (* span of contiguous non-blank rows *)
xOrigin * : FIXED; (* distance from upper left corner of bitmap *)
yOrigin * : FIXED; (* to initial CP, in fractional pixels *)
x0 * : INTEGER; (* approximation of XOrigin in whole pixels *)
y0 * : INTEGER; (* approximation of YOrigin in whole pixels *)
x1 * : INTEGER; (* approximation of XOrigin + Width *)
y1 * : INTEGER; (* approximation of YOrigin + Width *)
width * : FIXED; (* character advance, as fraction of em width *)
bitMap * : e.APTR; (* actual glyph bitmap *)
END;
GlyphWidthEntryPtr * = POINTER TO GlyphWidthEntry;
GlyphWidthEntry * = RECORD (e.MinNodeBase)
node * : e.MinNode; (* on list returned by widthList inquiry *)
code * : e.UWORD; (* entry's character code value *)
width * : FIXED; (* character advance, as fraction of em width *)
END;
(*
** $VER: oterrors.h 8.1 (19.6.92)
**
** oterrors.h -- error results from outline libraries
**
** (C) Copyright 1991-1992 Robert R. Burns
** All Rights Reserved
*)
CONST
(* PRELIMINARY *)
errFailure * = -1; (* catch-all for error *)
errSuccess * = 0; (* no error *)
errBadTag * = 1; (* inappropriate tag for function *)
errUnknownTag * = 2; (* unknown tag for function *)
errBadData * = 3; (* catch-all for bad tag data *)
errNoMemory * = 4; (* insufficient memory for operation *)
errNoFace * = 5; (* no typeface currently specified *)
errBadFace * = 6; (* typeface specification problem *)
errNoGlyph * = 7; (* no glyph specified *)
errBadGlyph * = 8; (* bad glyph code or glyph range *)
errNoShear * = 9; (* shear only partially specified *)
errNoRotate * = 10; (* rotate only partially specified *)
errTooSmall * = 11; (* typeface metrics yield tiny glyphs *)
errUnknownGlyph * = 12; (* glyph not known by engine *)
(**-- Library Base variable --------------------------------------------*)
CONST
diskfontName * = "diskfont.library";
VAR
base * : e.LibraryPtr;
(**-- Library Functions ------------------------------------------------*)
(*
** $VER: diskfont_protos.h 38.0 (18.6.92)
*)
PROCEDURE OpenDiskFont* [base,-30]
( VAR textAttr [8] : gfx.TextAttr )
: gfx.TextFontPtr;
PROCEDURE AvailFonts* [base,-36]
( VAR buffer [8] : ARRAY OF SYS.BYTE;
bufBytes [0] : LONGINT;
flags [1] : s.SET32 )
: LONGINT;
(* --- functions in V34 or higher (distributed as Release 1.3) ---*)
PROCEDURE NewFontContents* [base,-42]
( fontsLock [8] : d.FileLockPtr;
fontName [9] : ARRAY OF CHAR )
: FontContentsHeaderPtr;
PROCEDURE DisposeFontContents* [base,-48]
( fontContentsHeader [9] : FontContentsHeaderPtr );
(* --- functions in V36 or higher (distributed as Release 2.0) ---*)
PROCEDURE NewScaledDiskFont* [base,-54]
( sourceFont [8] : gfx.TextFontPtr;
VAR destTextAttr [9] : gfx.TextAttr )
: DiskFontHeaderPtr;
(**-- Library Base variable --------------------------------------------*)
<*$LongVars-*>
(**-----------------------------------*)
PROCEDURE* [0] CloseLib (VAR rc : LONGINT);
BEGIN (* CloseLib *)
IF base # NIL THEN e.CloseLibrary (base) END;
END CloseLib;
BEGIN
base := e.OpenLibrary (diskfontName, e.libraryMinimum);
IF base = NIL THEN HALT (100) END;
Kernel.SetCleanup (CloseLib)
END DiskFont.